package com.by.test.controller;

import com.by.test.util.AliyunOSSUtils;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
@Tag(name = "oss文件管理")
public class OssController {
    @Autowired
    AliyunOSSUtils aliyunOSSUtils;

    @PostMapping("/oss/upload")
    public String uplaod(MultipartFile file) throws IOException {
        log.info("上传过来的参数：{}", file.getOriginalFilename());
        //调用阿里云OSS工具类【AliOSSUtiles】进行文件上传
        String url = aliyunOSSUtils.upload(file);
        log.info("文件上传完成，url是：{}", url);

        return url;
    }
}
